# Maintainer: Bruno Pagani <archange@archlinux.org>

pkgname=python-numba
pkgver=0.58.1
pkgrel=1
pkgdesc="JIT compiler that translates a subset of Python and NumPy code into fast machine code"
url="https://numba.pydata.org/"
arch=(loong64 x86_64)
license=(BSD)
depends=(
  gcc-libs
  glibc
  python
  python-llvmlite
  python-numpy
)
makedepends=(
  onetbb
  openmp
  python-build
  python-installer
  python-setuptools
  python-wheel
)
optdepends=(
  'onetbb: TBB threading backend'
  'openmp: OpenMP threading backend'
  'python-cffi: use of CFFI bindings in compiled functions'
  'python-colorama: error message highlighting'
  'python-scipy: cython bindings used in np.linalg.* support'
  'python-jinja: “pretty” type annotation output (HTML) via the CLI'
  'python-pyelftools: for code generation'
  'python-pygments: “pretty” type annotation'
  'python-pyyaml: use of a .numba_config.yaml file for storing per project configuration options'
  'python-psutil: for sysinfo'
)
checkdepends=(
  gdb
  ipython
  python-cffi
  python-ipykernel
  python-jinja
  python-pexpect
  python-pip
  python-pygments
  python-pytest
  python-pyyaml
  python-scipy
)
source=(https://github.com/numba/numba/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('feaed9d9f67e4e8a88d88115419cac96bcb769922b471791632a8acca6e2f87e')

prepare() {
  cd numba-$pkgver
# Allow numpy 1.26
  sed -e 's|1.26|1.27|' -i setup.py
  sed -e 's|1, 25|1, 26|' -i numba/__init__.py
}

build() {
  cd numba-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer numba-$pkgver/dist/*.whl
  test-env/bin/python -m numba.runtests -b -v -m 64 -- numba.tests || true # numpy 1.25 support incomplete
}

package() {
  cd numba-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
